﻿using Learn.Infraestrutura.Attr;
using Learn.Infraestrutura.Dto.Request;
using Learn.Infraestrutura.Dto.Request.Org;
using Learn.Infraestrutura.Dto.Request.Right;
using Learn.Infraestrutura.Tools;
using Learn.Service.Interface;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Configuration;
using System.Security.Claims;

namespace Learning.Api.Admin.Controllers
{

    /// <summary>
    /// 组织架构
    /// </summary>
    public class OrgController : BaseController
    {

        private readonly IConfiguration _configuration;
        private readonly I_Org_Service _org_Service;

        public OrgController(I_Org_Service org_Service, I_Login_Service login_Service, IConfiguration configuration) : base(login_Service)
        {
            _configuration = configuration;
            _org_Service = org_Service;

        }

        

        [HttpGet]
        [Authorize(Roles = "admin")]
        public IActionResult Get_Dept(int pages=1,int limit=10,string key="") 
        {
            var result = _org_Service.Get_Dept(new Org_Request_Dto 
            {
                limit = limit,
                pages = pages,
                key=key
            });

            return Ok(result);
        }


        [HttpGet]
        [Authorize(Roles = "admin")]
        public IActionResult Get_Duties(int? page = 1, int? limit = 10, string key = "") 
        {
            var result = _org_Service.Get_Duties(new Org_Request_Dto 
            {
                pages = page??1,
                limit = limit??10,
                key=key??""
            });

            return Ok(result);
        }
    }
}
